<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="get" action="__SELF__">
      搜索：<input type="text" name="keyword" id="keyword" size="20"  value="<empty name="Think.get.keyword" >请输入搜索关键词<else />{$Think.get.keyword}</empty>" class="input-text" onclick="if(this.value=='请输入搜索关键词')this.value=''"  onblur="if(this.value=='')this.value='请输入搜索关键词'" style="height:20px;" />
      <select name="cid" id="cid" onchange="searchForm.submit();">
          <option value="0">未分类</option>
          <volist name="classifyList" id="vo">
            <option value="{$vo.id}" <if condition="$vo.id eq $_GET['cid']" > selected="selected"</if> />{$vo.name}</option>
          </volist>
      </select>
      <input type="submit" value=" 搜索 " class="button" />
    </form>
      <div class="content-menu" style="position: absolute; right: 30px;top: 5px;">
        <a href="javascript:openWinBox('__URL__/add','发布文章',800);" class="add fb"><em>发布文章</em></a>
      </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" action="" method="GET" id="myform">
    <div class="table-list">
    <table width="100%" cellspacing="0">
      <thead>
        <tr>
          <th align="center" width="50">选择</th>
          <th align="left" width="320">文章标题</th>
          <th align="left" width="120">所属分类</th>
          <th align="left" width="80">发布人</th>
          <th align="center" width="120">更新时间</th>
          <th align="center" width="120">操作</th>
        </tr>
      </thead>
      <tbody id="list">
        <volist name="list" id="vo">
          <tr id="list_{$vo.id}">
            <td align="center"><input type="checkbox" name="idArr[]" value="{$vo.id}"></td>
            <td align="left"><a href="http://www.haifangzj.com/news/aid-{$vo.aid}.html" target="_blank">{$vo.subject}</a></td>
            <td align="left">{$vo.category}</td>
            <td align="left">{$vo.mname}</td>
            <td align="center">{$vo.updatedate|date="Y-m-d H:i:s",###}</td>
            <td align="center">
            <a href="http://www.haifangzj.com/news/aid-{$vo.aid}.html" target="_blank">【浏览】</a>
            <a href="javascript:openWinBox('__URL__/add/id/{$vo.aid}','修改信息',800);">【修改】</a>
            </td>
          </tr>
        </volist>
      </tbody>
    </table>
    <div class="btn">
      <div id="pages">{$page}</div>
     	 <input name="submit" id="checkall" type="button" class="button" value="全选/反选">
     	 <input name="submit" type="button" class="button" value="删除所选"  onclick="return deleteConfirm();">
    </div>
  </form>
</div>
</body>
</html>
<script type="text/javascript">
$(function(){
	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		var len = $("input[name='idArr[]']:checked").length;
		if(len < 1){
			msg('先选择删除项！','warning',4);
			return false;
		}
	}

	var origin = $.artDialog.open.origin;

	function complete(data){
		msg(data.info,data.data);
		if(data.status) setTimeout(function(){origin.location.reload();},1500);
	}

	$('#category_id').change(function(){
		$("#searchForm").submit();
	})

	$('input[name=keyword]').change(function(){
		$("#searchForm").submit();
	})

	//全反选
	$("#checkall").click(function(){
		$("input[name=idArr[]]").each(function(){
			if(this.checked == false)
				this.checked = true;
			else
				  this.checked = false;
		});
	});
})

function deleteConfirm(){
	art.dialog({
		content: '确定删除所选数据吗？',
		ok: function () {
			del();
			return true;
		},
		cancelVal: '取消',
		cancel: true
	});
}

function del(){
	var idArr = Array();
	var i = 0;
	var id;
	$("input[name='idArr[]']").each(function(){
		if(this.checked == true){
			idArr[i] = $(this).val();
			i++;
		}
	});

	jQuery.post('__URL__/del',encodeURI('id='+idArr),success,'json');
	function success(data){
		if(data.status==1){
			window.top.art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'succeed'});
		}else{
			window.top.art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'warning'});
		}
		setTimeout(function(){window.location.reload();closeWin(1000);},1000);
	}
}
</script>